<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改视频</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" type="text/css" th:href="@{/js/layui/css/layui.css}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/cba/style.css/}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/cba/my.css/}" media="all">
</head>
<body class="childrenBody">
<form class="layui-form html_save" lay-filter="form">
    <div class="layui-form-item">
        <label class="layui-form-label">视频标签（多个标签通过","分隔）</label>
        <div class="layui-input-block">
            <input class="layui-input" name="tag" placeholder="请输入标签" type="text">
            <input class="layui-input" name="id" id="id" type="hidden">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">商品标题</label>
        <div class="layui-input-block">
            <input class="layui-input" name="title" placeholder="请输入商品标题" type="text">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">商品链接</label>
        <div class="layui-input-block">
            <input class="layui-input" name="linkUrl" placeholder="请输入商品链接" type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品价格</label>
        <div class="layui-input-block">
            <input class="layui-input" name="goodsPrice" placeholder="请输入商品价格" type="text" lay-verify="number">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">商品优惠信息</label>
        <div class="layui-input-block">
            <input class="layui-input" name="discountInfo" placeholder="请输入优惠信息" type="text">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">销量</label>
        <div class="layui-input-block">
            <input class="layui-input" name="sales" lay-verify="number" value="0" placeholder="请输入销量" type="text">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序（权重）</label>
        <div class="layui-input-block">
            <input class="layui-input" name="sort" lay-verify="number" value="0" placeholder="请输入序数" type="text">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="saveContainer">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script th:src="@{/js/layui/layui.js}"></script>
<script th:src="@{/js/cba/login-timeout.js}"></script>
<!--<script type="text/javascript" src="js/newsadd.js"></script>-->

<script type="text/javascript" th:inline="javascript">
    layui.use(['table', 'form', "layer"], function () {

        // 操作对象
        var form = layui.form
            , table = layui.table
            , layer = layui.layer
            , $ = layui.jquery;

        var video = [[${video}]];
        if (video != null) {
            form.val("form", {
                "tag": video.tag // "name": "value"
                , "title": video.title
                , "linkUrl": video.linkUrl
                , "discountInfo": video.discountInfo
                , "sort": video.sort
                , "sales": video.sales
                , "goodsPrice": video.goodsPrice
                , "id": video.id
            });
        }



        //监听提交
        form.on('submit(saveContainer)', function (data) {
            $.ajax({
                url: [[${basePath}]] + "/video/save", data: data.field, sync: "post", success: function (data) {
                    if (data.success) {
                        layer.msg(data.msg, {icon: 1});
                        setTimeout(function () {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.location.href = [[${basePath}]] + "/video/index";
                            parent.layer.close(index);
                        }, 1500);
                    } else {
                        layer.msg(data.msg, {icon: 5});
                    }
                }
            });

            return false;
        });

    });
</script>
</body>
</html>